package com.kaishengit.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.entity.Project;
import com.kaishengit.service.NewProjectService;
import com.kaishengit.util.DateUtil;
import com.kaishengit.util.PKUtil;

public class New_projectServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	

	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String _m = request.getParameter("_m");
		if("new_project".equals(_m)) {
			newProject(request, response);
		}else if("".equals(_m) || _m==null) {
			request.getRequestDispatcher("/WEB-INF/views/new_project.jsp").forward(request, response);
		}
	}


	private void newProject(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
		
		String name = request.getParameter("name");
		String desc = request.getParameter("desc");
		String fuZeRen = request.getParameter("fuZeRen");
		String xiangMuChengYuan =  request.getParameter("xiangMuChengYuan");
		String createtime = DateUtil.getNow();
		System.out.print(createtime);
		
		NewProjectService newPro = new NewProjectService();
		newPro.addEmPro(name, desc, fuZeRen, xiangMuChengYuan, createtime);
		
		
		
		request.getRequestDispatcher("main.jspx").forward(request, response);
		
		
	}

}
